function get(url,callback){
    var ajax = new XMLHttpRequest();
    //回调函数
    ajax.onreadystatechange = ()=>{
        if (ajax.readyState==4 && ajax.status==200){
            var json = ajax.responseText;
            var result = JSON.parse(json);
            callback(result);
        }
    }
    ajax.open("get",url);
    ajax.send(null);
}

function post(url,data,callback){
    var ajax = new XMLHttpRequest();
    //回调函数
    ajax.onreadystatechange = ()=>{
        if (ajax.readyState==4 && ajax.status==200){
            var json = ajax.responseText;
            var result = JSON.parse(json);
            callback(result);
        }
    }
    ajax.open("post",url);
    if (data instanceof String){
        //表单提交参数
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
    }else if (data instanceof FormData){
        ajax.setRequestHeader("Content-Type","multipart/form-data");
    }
    ajax.send(data);
}
